# README

Note that at the start of each .do, .R or .Rmd file, you will need to update the working directory. Unless stated otherwise, the working directory should be set to the folder containing the code (root). 

The trees structure should be:

. (SM / root)

|-- CACE

​		|-- |--fig_lgbt

​		|-- |--fig_immigration

|-- surveys

The pre-analysis plan is available at https://osf.io/gw8b7/?view_only=6c206c3d79694d93a9bf6322eb3eab4b. 

## Data

- `tv_experiment_sm_data.csv`: This contains the raw data for everyone in the study. These variables are described in `codebook.csv`.
- Note that we cannot release the raw data for the CACE/dosage effect analyses. Instead, these results are reported in `imm_cace_results_decay.xlsx`, `immigration_cace_results.csv`, `lgbt_cace_results.csv`, and `lgbt_cace_results_decay.csv`.
- All data reported was originally collected for this study.

## Code

- `SM_Immigration_Trans_TV_Ad_Experiment.Rmd`: This is the main code. Note that you must first run `CACE/make_immigration_cace_graph.R` and   `CACE/make_lgbt_cace_graph.R` before you can run this .Rmd file. This .Rmd file produces:
  - `SM_Immigration_Trans_TV_Ad_Experiment.pdf`: This is the online appendix.
  - `lgbt_main_results_graph.pdf`: This is Figure 2 in the main text. See Line 1177 in the .Rmd file.
  - `imm_main_results_graph.pdf`: This is Figure 3 in the main text. See Line 1031 in the .Rmd file.
- `CACE/make_immigration_cace_graph.R`: This produces Figures OA3-7 in the online appendix. The working directory should be set to the `fig_immigration` folder.
- `CACE/make_lgbt_cace_graph.R`: This produces Figures OA8-11 in the online appendix. The working directory should be set to the `fig_lgbt` folder.
- `multiple testing adjustment for lgbt ad.do`: This produces Table OA40 and was not a pre-registered analysis. Note that this code is **very slow**.
- `CACE/dosage.do`: This is the linear model referenced in the "Dosage Effects" section of the online appendix.

## Survey Instruments

- `surveys/baseline.docx`: This is the initial baseline survey (t0).
- `surveys/endline.docx`: This is the final endline survey (t1).

# Software and Package Versions

- Platform: x86_64-apple-darwin17.0 running under macOS  10.16.
- R: 4.0.2 (2020-06-22)
- R Packages Required:
  - dplyr_1.0.5
  - ggplot2_3.3.3
  - scales_1.1.1
  - ebal_0.1-6
  - plyr_1.8.6
  - forcats_0.5.0
  - purrr_0.3.4
  - readr_1.3.1
  - tidyr_1.1.3
  - tibble_3.1.1
  - tidyverse_1.3.0
  - gridExtra_2.3
  - stringr_1.4.0
  - kableExtra_1.2.1
  - lmtest_0.9-38
  - zoo_1.8-8
  - sandwich_3.0-0
  - captioner_2.2.3
  - bookdown_0.20
  - pander_0.6.3
  - knitr_1.30
- Stata/SE 14.2

## Contact Information

For questions about the replication data and code, contact Joshua Kalla (josh.kalla@yale.edu) or David Broockman (dbroockman@berkeley.edu).

